package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.DeleteMapping;

import java.util.List;

/**
 * 目标：
 *
 * @author Ashely
 * @date 2024/6/17 10:23
 */
@Mapper
public interface ShoppingCartMapper {
@Insert("insert into shopping_cart(user_id,dish_id,dish_flavor,setmeal_id,name,image,number,amount,create_time) values(#{userId},#{dishId},#{dishFlavor},#{setmealId},#{name},#{image},#{number},#{amount},#{createTime})")
@Options(useGeneratedKeys = true,keyProperty = "id")
    void add(ShoppingCart shoppingCart);
@Update("update shopping_cart set number = #{number} where id = #{id}")
    void update(ShoppingCart shoppingCart);
    List<ShoppingCart> list(ShoppingCart shoppingCart);
@Delete("delete from shopping_cart where user_id = #{userId}")
    void clean(Long userId);
@Delete("delete from shopping_cart where id = #{id}")
    void delete(Long id);

    void insertBatch(List<ShoppingCart> shoppingCartList);
}
